<template>
    <div class="newsinfo-container">
        <h3 class="title">{{newsInfo.title}}</h3>

        <div class="subtitle">
             <span>{{newsInfo.add_time | dateFormat}}</span>
             <span>{{newsInfo.click}}</span>
        </div>
        <hr/>

        <div class="content" v-html="newsInfo.content"></div>

        <comment-box></comment-box>
    </div>
</template>

<script>
import Toast from 'mint-ui';
import comment from './components/subComponents/comment.vue'
export default {
  data() {
    return {
      newsInfo:[],
      id: this.$route.params.id,
    }
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo(){
      this.$http.get("news.json").then(result=>{
        if (result.body) {
          var opj=result.body.filter(itme=>{
            if (itme.id==this.id) {
              return itme;
            }
          })[0];
          this.newsInfo=opj;
        } else {
          Toast("没有获取到数据！！！！")
        }
      })
    }
  },
  components:{
    "comment-box":comment
  }
}
</script>
<style lang="scss">
.newsinfo-container {
    padding: 0 4px;
    .title {
      font-size: 16px;
      text-align: center;
      margin: 15px 0;
      color: red;
    }
    .subtitle {
      font-size: 13px;
      color: #226aff;
      display: flex;
      justify-content: space-between;
    }
    .content {
      img {
        width: 100%;
      }
    }
}
</style>